
import 'dart:convert';

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }
  return null;
}

class SubCategory {
  SubCategory({
    this.id,
    this.name,
  });

  factory SubCategory.fromJson(Map<String, dynamic> jsonRes) {
    if(jsonRes==null)return null;
    String id=jsonRes['id'].toString();
    return SubCategory(id: id,name: asT<String>(jsonRes['name']));
  }

  String id;
  String name;

  Map<String, dynamic> toJson() => <String, dynamic>{
    'id': id,
    'name': name,
  };
  @override
  String toString() {
    return json.encode(this);
  }
}
